#include "Network.h"
#include "Server.h"
#include "AdminChannelManager.h"
#include "AdminChannel.h"
#include "AdminUser.h"
#include "AdminDatabase.h"
#include "AdminConfiguration.h"
#include "AdminInterpreter.h"
#include "AdminChannelManager.h"
#include "AdminUserManager.h"


using namespace AgoraServer;

int main()
{

	AgoraAdmin::Database *db = new AgoraAdmin::Database();
	AgoraAdmin::Configuration::GetConfiguration()->InitDatabase(db);
	if (db->Open("./test"))
	//if (db->Open("./test") != 0)
	{
		std::cout << "Could not open database" << std::endl;
		return 1;
	}

	std::string	ip;
	int portA, portS;
	std::cout << "ip :";
	std::cin >> ip;
	std::cout << "admin port:";
	std::cin >> portA;
	std::cout << "sound port:";
	std::cin >> portS;

	

	AgoraCore::AgoraNetworkInitialize();
	Server *s = new Server();
	s->Start(portS, portA, ip);
	//s->Start(21, 22, "192.168.1.21");

	std::cout << "Server started on " << ip << std::endl;
	while (true)
	{
#ifdef _WIN32
		Sleep(40);
#else
		usleep(40);
#endif
	}
	AgoraCore::AgoraNetworkFinalize();	
	return 0;
}
